<?php
//$basePath = Yii::getPathOfAlias('application.modules.order');
//$baseUrl = Yii::app()->getAssetManager()->publish($basePath);
?>
<div class="order-box">
    <ol class="flow-steps">
        <li class="current_a"><span class="first">1.Select Product</span></li>
        <li class="current_a"><span>2.Comfirm Information</span></li>
        <li class="current_a"><span>3.Check Out</span></li>
        <li class="finish"><span>4.Payment Processing</span></li>
        <div class="clear"></div>
    </ol>
    <br/>
    <form id="toPaypal" action="<?php echo $paypal->paypalUrl[$paypal->runType]['url']; ?>" method="post" style="min-height: 200px;text-align: center;font-size: 16px;" />
    <h1 style="margin-top: 20px;margin-bottom: 2px;font-family: Helvetica, sans-serif, Arial!important;">Redirecting to Payment Page...</h1>
    <img src="<?php echo $this->baseUrl; ?>/images/loading.gif" />
    <div style="margin-bottom: 5px;margin-top: 10px;">
        Please do not close the browser while redirecting. If this page does not redirect, click the Pay Button Below!
    </div>
    
    <input type="hidden" name="cmd" value="_xclick" />
    <input type="hidden" name="business" value="<?php
if ($paypal->runType == 'sandbox') {
    echo $paypal->paypalUrl[$paypal->runType]['business'];
} else {
    $subsite = WebOption::model()->find();
    if (!empty($subsite->paymail)) {
        echo $subsite->paymail;
    } else {
        echo $paypal->paypalUrl[$paypal->runType]['business'];
    }
}
?>" />
           <?php
           $item_name = array();
           foreach ($items as $item) {
               $item_name[] = $item->name . ':' . $item->num;
           }
           ?>
    <input type="hidden" name="quantity" value="1" />
    <input type="hidden" name="item_name" value="<?php echo join('|', $item_name); ?>" />
    <input type="hidden" name="invoice" value="<?php echo $order->order_number; ?>" />
    <input type="hidden" name="amount" value="<?php echo round($order->total_price - $order->offset, 2); ?>" />
    <input type="hidden" name="currency_code" value="<?php echo $order->currency_tag; ?>" />
    <input type="hidden" name="return" value="<?php echo Yii::app()->createAbsoluteUrl('order/order/access'); ?>" />
    <input type="hidden" name="cancel_return" value="<?php echo Yii::app()->createAbsoluteUrl('order/order/cart'); ?>" />
    <input type="hidden" name="notify_url" value="<?php echo Yii::app()->createAbsoluteUrl('order/order/ipn'); ?>" />
    <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" />
    <br/>
    <h1>Your Order Number: <?php echo $_SESSION['order_number']; ?></h1>
</form>
</div>
<?php
$cs = Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
?>
<script>
    $(window).load(function(){
        $("#toPaypal").submit();
    });
</script>